package com.qitmiaojie.controller.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result implements Serializable {
    protected Integer StateCode;//状态码,
    protected String Msg;//信息
    protected Object object;
    public static <T> Result success(T object) {
        Result r = new Result();
        r.setMsg("操作成功！");
        r.object = object;
        r.setStateCode(200);
        return r;
    }
//    public static <T> Result success(String msg) {
//        Result r = new Result();
//        r.setMsg(msg);
//        r.object = null;
//        r.setStateCode(200);
//        return r;
//    }
    public static <T> Result success(String msg,T object) {
        Result r = new Result();
        r.object = object;
        r.setMsg(msg);
        r.setStateCode(200); //200 ok
        return r;
    }
    public static <T> Result error(String msg) {
        Result r = new Result();
        r.object = null;
        r.setMsg(msg);
        r.setStateCode(500);
        return r;
    }
}
